home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
util
/
cli
/
bb2cli.lha
/
BBgoesCLI
/
ShowBB.asm
< prev
Wrap
Assembly Source File
|
1992-09-02
|
4KB
|
192 lines
**********************************************************
* ShowBB v1.0 22.12.1994 *
**********************************************************
* copyright (c) 1994 by Jens Tröger, all rights reserved *
* this is Public Domain *
**********************************************************
* written using HiSoft`s DevPac 3.04 *
* greets fly to Oliver Reiff, "PackMAN" Falk Zühlsdorff *
* "Janosh" Jan Stötzer, Jan van den Baard,... *
**********************************************************
* (non)sense: this will read the Bootblock from a given *
* floppy-drive and then write to stdio *
* works with KS1.2 and better *
* USAGE: ShowBB <unit> *
**********************************************************
opt o+,p+
move.l a0,a5
; ----- alloc memory for bootblock and several structures
alloc_mem move.l 4.w,a6
move.l #1024+88,d0 ; Bootblock + Port/IO...
move.l #$10001,d1
jsr -198(a6) ; _LVOAllocMem
move.l d0,a4 ; a4: PTR to mem
beq exit
; ----- open dos.library
open_dos lea dosname(pc),a1
moveq #33,d0
jsr -552(a6) ; _LVOOpenLibrary
move.l d0,d6 ; d6: DOSBase
beq free_mem
; ----- get unit
read_unit cmp.b #"d",(a5)+
bne usage
cmp.b #"f",(a5)+
bne usage
moveq #0,d0
move.b (a5)+,d0
sub.b #48,d0
cmp.b #4,d0
bge usage
cmp.b #0,d0
blt usage
move.l d0,d2 ; d2: Unit
cmp.b #":",(a5)+
bne usage
adda.l #1,a5
move.l a5,a0
.loop cmp.b #10,(a0)+
bne.s .loop
move.b #0,-(a0)
; ----- add MessagePort to system
add_port sub.l a1,a1
jsr -294(a6) ; _LVOFindTask
move.l d0,1024+16(a4)
lea 1024(a4),a1
jsr -354(a6) ; _LVOAddPort
; ----- open trackdisk.device
open_track lea trackname(pc),a0
lea 1024+32(a4),a1 ; a1: DiskIO-Struc
move.l d2,d0
moveq #0,d1
jsr -444(a6) ; _LVOOpenDevice
tst.l d0
bne err_nodev ; FATAL !!!!!
; ----- read bootblock
read_bb lea 1024+46(a4),a0 ; a0: RepPort
lea 1024(a4),a1 ; a1: ReplyPort-Struc
move.l a1,(a0)
lea 1024+32(a4),a1 ; a1: DiskIO-Struc
move.w #2,28(a1)
move.l #1024,36(a1)
move.l a4,40(a1)
move.l #0,44(a1)
jsr -456(a6) ; _LVODoIO
move.l d0,d2
move #9,28(a1)
move.l #0,36(a1)
jsr -456(a6) ; _LVODoIO
tst.l d2
bne.s err_nodoio
; ----- close trackdisk.device
close_dev lea 1024+32(a4),a1 ; a1: DiskIO-Struc
jsr -450(a6) ; _LVOCloseDevice
; ----- remove port
rem_port lea 1024(a4),a1 ; a1: ReplyPort
jsr -360(a6) ; _LVORemPort
; ----- make good (overwrite all non-writeable bytes with a point)
make_good move.l a4,a3
move.l #1023,d0
.loop cmp.b #" ",(a3)+
ble.s .make
dbra d0,.loop
bra.s write
.make move.b #".",-1(a3)
dbra d0,.loop
; ----- write to stdio
write move.w #$0a0a,1024(a4)
move.l a4,a2
move.l #1026,d3
bsr.s write_msg
; ----- close dos.library
close_dos move.l 4.w,a6
move.l d6,a1
jsr -414(a6) ; _LVOCloseLibrary
; ----- free allocated memory
free_mem move.l a4,a1
move.l #1024+88,d0
jsr -210(a6) ; _LVOFreeMem
; ----- returncode: 0
exit moveq #0,d0
rts
; ----- several messages
usage lea usage_text(pc),a2
move.l #usage_text_end-usage_text,d3
bsr.s write_msg
bra close_dos
err_nodev lea err1_text(pc),a2
moveq #38,d3
bsr.s write_msg
move.l 4.w,a6
lea 1024(a4),a1 ; a1: ReplyPort
jsr -360(a6) ; _LVORemPort
bra.s close_dos
err_nodoio lea err2_text(pc),a2
moveq #44,d3
bsr.s write_msg
move.l 4.w,a6
lea 1024+32(a4),a1 ; a1: DiskIO-Struc
jsr -450(a6) ; _LVOCloseDevice
lea 1024(a4),a1 ; a1: ReplyPort
jsr -360(a6) ; _LVORemPort
bra.s close_dos
; ----- write 2 stdio
write_msg move.l d6,a6
jsr -60(a6) ; _LVOOutput
move.l d0,d1
move.l a2,d2
jmp -48(a6) ; _LVOWrite
; ----- names, texts
dosname dc.b "dos.library",0
even
trackname dc.b "trackdisk.device",0
even
err1_text dc.b "FATAL ERROR opening trackdisk.device.",10
even
err2_text dc.b "Error reading Bootblock. No disk inserted ?",10
even
usage_text dc.b 10,$9b,"1mShowBB v1.0",$9b,"0m 1994 by Jens Tröger",10
dc.b "USAGE: ShowBB <unit>",10
dc.b "Where <unit> is one of your mounted floppies (df0:) "
dc.b 10,10
usage_text_end
end